<style type="text/css">
    .layui-form-select dl{z-index:9999;}
</style>
<form class="layui-form layui-form-pane" action="{:url()}" method="post" id="editForm">
<div class="page-form">
    
    <div class="layui-form-item">
        <label class="layui-form-label">轮播图名称</label>
        <div class="layui-input-inline w200">
            <input type="text" class="layui-input field-name" name="name" lay-verify="required" autocomplete="off" placeholder="前台不展示随便填">
        </div>
        <div class="layui-form-mid layui-word-aux">必填项</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图片</label>
            <div class="layui-input-inline upload">
                <button type="button" name="img" class="layui-btn layui-btn-primary layui-upload" lay-type="image" lay-data="{accept:'image'}">请上传图片</button>
                <input type="hidden" class="upload-input field-img" name="img">
                {if condition="!empty($data_info['img'])"}
                <img src="{$data_info['img']}" style="border-radius:5px;border:1px solid #ccc" width="36" height="36">
                {else /}
                <img src="" style="display:none;border-radius:5px;border:1px solid #ccc" width="36" height="36">
                {/if}
            </div>
            <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">跳转类型</label>
        <div class="layui-input-inline">
            <input type="radio" class="field-type" name="type" value="1" title="小程内页面" checked>
            <input type="radio" class="field-type" name="type" value="2" title="其他小程序">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">跳转地址</label>
        <div class="layui-input-inline w200">
            <input type="text" class="layui-input field-url" name="url" autocomplete="off" placeholder="例如/pages/imToken/index">
        </div>
        <div class="layui-form-mid layui-word-aux">小程序内页面地址</div>
    </div>
     <div class="layui-form-item">
        <label class="layui-form-label">appid</label>
        <div class="layui-input-inline w200">
            <input type="text" class="layui-input field-appid" name="appid"  autocomplete="off" placeholder="例如/pages/imToken/index">
        </div>
        <div class="layui-form-mid layui-word-aux">其他小程序appId</div>
    </div>
     <div class="layui-form-item">
        <label class="layui-form-label">小程序path</label>
        <div class="layui-input-inline w200">
            <input type="text" class="layui-input field-path" name="path" autocomplete="off" placeholder="例如/pages/imToken/index">
        </div>
        <div class="layui-form-mid layui-word-aux">其他小程序path</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">顺序</label>
        <div class="layui-input-inline w200">
            <input type="text" class="layui-input field-shunxu" name="shunxu" lay-verify="required" autocomplete="off" placeholder="单位数字，数字越大越靠前">
        </div>
        <div class="layui-form-mid layui-word-aux">必填项</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态设置</label>
        <div class="layui-input-inline">
            <input type="radio" class="field-status" name="status" value="1" title="启用" checked>
            <input type="radio" class="field-status" name="status" value="0" title="禁用">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" class="field-id" name="id">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="formSubmit">提交</button>
            <a href="{:url('index')}" class="layui-btn layui-btn-primary ml10"><i class="aicon ai-fanhui"></i>返回</a>
        </div>
    </div>
</div>
</form>
{include file="admin@block/layui" /}
<script>
var formData = {:json_encode($data_info)};
layui.use(['upload'], function() {
    var $ = layui.jquery, layer = layui.layer, upload = layui.upload;
    /**
     * 附件上传url参数说明
     * @param string $from 来源
     * @param string $group 附件分组,默认sys[系统]，模块格式：m_模块名，插件：p_插件名
     * @param string $water 水印，参数为空默认调用系统配置，no直接关闭水印，image 图片水印，text文字水印
     * @param string $thumb 缩略图，参数为空默认调用系统配置，no直接关闭缩略图，如需生成 500x500 的缩略图，则 500x500多个规格请用";"隔开
     * @param string $thumb_type 缩略图方式
     * @param string $input 文件表单字段名
     */
    upload.render({
        elem: '.layui-upload'
        ,url: '{:url("admin/annex/upload?thumb=no&water=no")}'
        ,method: 'post'
        ,before: function(input) {
            layer.msg('文件上传中...', {time:3000000});
        },done: function(res, index, upload) {
            var obj = this.item;
            if (res.code == 0) {
                layer.msg(res.msg);
                return false;
            }
            layer.closeAll();
            var input = $(obj).parents('.upload').find('.upload-input');
            if ($(obj).attr('lay-type') == 'image') {
                input.siblings('img').attr('src', res.data.file).show();
            }
            var curWwwPath = window.document.location.href;
            var pathName = window.document.location.pathname;
            var pos = curWwwPath.indexOf(pathName);
        
            console.log(curWwwPath.substring(0, pos) + res.data.file);
            input.val(curWwwPath.substring(0, pos) +res.data.file);
        }
    });
});
</script>
{:editor(['content'])}

<script>
var formData = {:json_encode($data_info)};
</script>
<script src="__ADMIN_JS__/footer.js"></script>